//
//  XMRemarkTableViewCell.m
//  XiaoMiao
//
//  Created by Jim huang on 2018/4/26.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "XMRemarkTableViewCell.h"

@interface XMRemarkTableViewCell ()<UITextViewDelegate>


@end

@implementation XMRemarkTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}

-(void)setUI{
    [self.remarkTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);

    }];
    
    [self.placeHolderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(8);
        make.left.equalTo(self.remarkTextView).offset(5);
        
    }];
    
}

#pragma mark - textviewDelegate
-(void)textViewDidChange:(UITextView *)textView{
    self.placeHolderLabel.hidden = textView.text.length;
    if (self.textChangeBlock) {
        self.textChangeBlock(textView.text);
    }
}


#pragma mark ----getting&setting----
-(UITextView *)remarkTextView{
    if (!_remarkTextView) {
        _remarkTextView = [[UITextView alloc]init];
        _remarkTextView.textColor = kTextBlackColor;
        _remarkTextView.font = kFont(14);
        _remarkTextView.delegate = self;
        [self.contentView addSubview: _remarkTextView];
    }
    return _remarkTextView;
}

-(UILabel *)placeHolderLabel{
    if (!_placeHolderLabel) {
        _placeHolderLabel = [[UILabel alloc]init];
        _placeHolderLabel.textColor = kTextGrayColor;
        _placeHolderLabel.font = kFont(14);
        [self.contentView addSubview: _placeHolderLabel];
    }
    return _placeHolderLabel;
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
